Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where assert 0xb7b incorrectly fires when flushing empty batches during reentrant operations. The assert was designed to prevent reentrancy issues when flushing operations, but it triggered even when there were no operations to flush, which is safe.
Key Changes:
- Modified the assert to only check for reentrancy when there are actual batches to flush
- Removed the intermediate
flushAllmethod and consolidated logic intoflush - Added test coverage for both empty and non-empty batch flush scenarios during reentrant state
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/runtime/container-runtime/src/opLifecycle/outbox.ts | Moved reentrancy assertion to only trigger when batches are non-empty, consolidated flushAll into flush, and added assertion with string message in flushResubmittedBatch |
| packages/runtime/container-runtime/src/test/opLifecycle/outbox.spec.ts | Added two test cases to verify the fix: one confirming no assertion with empty batches during reentrancy, and another confirming assertion still fires with non-empty batches |
| assert( | ||
| !this.isContextReentrant(), | ||
| "Flushing must not happen while incoming changes are being processed", | ||
| ); |
There was a problem hiding this comment.
New assert added with string literal message instead of hex code. Per coding guidelines (CodingGuidelineID: 1000000), asserts from @fluidframework/core-utils should use string literals for error messages, not hex codes. This is correctly implemented here.
There was a problem hiding this comment.
we really need to remove this copilot instruction. it is always wrong
Previous fix opened up a possible regression under `maybeFlushPartialBatch`
There's a corner case where processing incoming ops (join/leave ops in particular) can trigger a connection state transition which can trigger a flush (but there are no changes to flush), and assert 0xb7b fires - it asserts that we should never flush while processing incoming ops. This protects against reentrancy, which is not an issue in this case. The fix is to only assert if we have something to flush.
Description
Fixes AB#48146
There's a corner case where processing incoming ops (join/leave ops in particular) can trigger a connection state transition which can trigger a flush (but there are no changes to flush), and assert 0xb7b fires - it asserts that we should never flush while processing incoming ops. This protects against reentrancy, which is not an issue in this case.
The fix is to only assert if we have something to flush.